def myPrint(*args, sep=' ', end='\n', file=None, flush=False):
    """
    A custom print function that mimics the behavior of the built-in print function.

    :param args: The items to print.
    :param sep: The separator between items.
    :param end: The ending character.
    :param file: The file to print to.
    :param flush: Whether to flush the output.
    """
    if file is None:
        file = sys.stdout

    for arg in args:
        file.write(str(arg) + sep)

    # Remove the last separator and write the ending character
    file.write(file.getvalue()[:len(file.getvalue())-len(sep)] + end)

    if flush:
        file.flush()

# Example usage:
myPrint("Hello", "world", sep='-', end='\n', flush=True)